package co.msk8.server.action.commands;

import co.msk8.client.command.action.SumAction;
import co.msk8.client.command.result.SumResult;
import co.msk8.server.action.ActionHandler;
import co.msk8.server.calculator.Calculator;
import co.msk8.server.calculator.CalculatorFactory;
import co.msk8.server.calculator.CalculatorFactory.CalculatorType;

public class SumCommand implements ActionHandler<SumAction, SumResult> {
	
	Calculator calculator = CalculatorFactory.createCalculator(CalculatorType.SIMPLE);

	public Class<SumAction> getActionType() {
		return SumAction.class;
	}

	public SumResult execute(SumAction action) throws Exception {
		
		
		SumResult result = new SumResult(calculator.getAddition(action.getA(), action.getB()));
		return result;
	}

}
